clear all
set more off
set scheme s2color
cd ""

use "sample.dta", clear

qui tab prov_code, gen(prov_code)
forvalues i = 1/24 {
gen provXtime`i' = prov_code`i'*time
}
qui tab time, gen(time_fe)

****************
* Subfigure (1)
****************

#delimit ;
binscatter in_confn14 d_movewithin, absorb(city_code)
           controls(wdsp temp prcp time_fe* provXtime*) 
           msymbols(circle) mcolors(black) lcolors(black)
           ytitle("New infections (logged and lagged 14 days)")
           xtitle("Mobility percentage change (move-within)")
           ylabel(, labsize(small) tlength(0.8) grid glwidth(vthin) nogextend)
           xlabel(, labsize(small) tlength(0.8))
           graphregion(fcolor(white) color(white) icolor(white) ilstyle(p1box)
           margin(small)) plotregion(margin(vsmall));
#delimit cr

****************
* Subfigure (2)
****************

#delimit ;
binscatter d_movewithin bdindexS7_std, absorb(city_code)
           controls(wdsp temp prcp time_fe* provXtime*) 
           msymbols(circle) mcolors(black) lcolors(black)
           ytitle("Mobility percentage change (move-within)")
           xtitle("Citizen discontent (standardized moving average)")
           ylabel(, labsize(small) tlength(0.8) grid glwidth(vthin) nogextend)
           xlabel(, labsize(small) tlength(0.8))
           graphregion(fcolor(white) color(white) icolor(white) ilstyle(p1box)
           margin(small)) plotregion(margin(vsmall));
#delimit cr
